// import { message } from 'antd';
import { postData, exportData } from './index'

export default {
    /* 活动管理 */
    //活动列表
    getActivitiesList:(data, callback)=>{
        return postData('/market/activities/list',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
    addActivities:(data, callback)=>{
        return postData('/market/activities/add',data).then((res) => {
            if(res){
                callback(res);
            }else{
                callback(false)
            }
        }).catch((err)=>{
            callback(false)
        })
    },
    editActivities:(data, callback)=>{
        return postData('/market/activities/edit',data).then((res) => {
            if(res){
                callback(res);
            }else{
                callback(false)
            }
        }).catch((err)=>{
            callback(false)
        })
    },

    /* 参与用户 */
    // 参与用户列表
    getActivitiesUserList:(data, callback)=>{
        return postData('/market/activities/userList',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
    // 积分记录列表
    getUserIntegralList:(data, callback)=>{
        return postData('/market/activities/userPointsFlow/list',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
    // 奖品记录列表
    getUserGiftList:(data, callback)=>{
        return postData('/market/activities/userGoods/listByUserId',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },

    /* 分发渠道 */
    // 分发渠道列表
    getChannelDataList:(data, callback)=>{
        return postData('/market/activities/channelData/list',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
    // 新增分发渠道
    addChannelData:(data, callback)=>{
        return postData('/market/activities/channelData/add',data).then((res) => {
            console.log(res)
            if(res || res==''){
                callback(true);
            }else{
                callback(false)
            }
        }).catch((err)=>{
            callback(false)
        })
    },
    // 更新分发渠道状态
    updateStateChannelData:(data, callback)=>{
        return postData('/market/activities/channelData/updateState',data).then((res) => {
            if(res || res==''){
                callback(true);
            }else{
                callback(false);
            }
        })
    },
    // 角色下拉框
    getRoleList:(data, callback)=>{
        return postData(process.env.Text[3]+'/center/sys/role/roleList',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
    // 批量生成员工渠道
    addByRoleName:(data, callback)=>{
        return postData('/market/activities/channelData/addByRoleName',data).then((res) => {
            if(res || res==''){
                callback(true);
            }else{
                callback(false);
            }
        })
    },
    //导出分发渠道
    exportChannelData:(data, callback)=>{
        return exportData('/market/activities/channelData/export',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },

    /* 奖品管理 */
    // 奖品列表
    getActivitiesGoodsList:(data, callback)=>{
        return postData('/market/activities/goods/goodsList',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
    // 新增编辑奖品
    addActivitiesGoods:(data, callback)=>{
        return postData('/market/activities/goods/addGoods',data).then((res) => {
            console.log(res)
            if(res){
                callback(res);
            }else{
                callback(false);
            }
        }).catch((err)=>{
            callback(false)
        })
    },
    // 已兑换奖品列表（下拉框用）
    getGoodsAllList:(data, callback)=>{
        return postData('/market/activities/goods/goodsAllList',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },

    /* 课程管理 */
    // 课程列表
    getActivitiesClassList:(data, callback)=>{
        return postData('/market/activities/class/classList',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
    // 新增编辑课程
    addActivitiesClass:(data, callback)=>{
        return postData('/market/activities/class/addClass',data).then((res) => {
            console.log(res)
            if(res){
                callback(res);
            }else{
                callback(false);
            }
        }).catch((err)=>{
            callback(false)
        })
    },
    // 项目类型下拉框
    getProjectType:(data, callback)=>{
        return postData(process.env.Text[3]+'/center/product/projecttype/listAll',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
    // 根据项目类型和名称查找学习计划
    getTeachPlan:(data, callback)=>{
        return postData('/market/activities/class/getTeachPlanByProjectType',data).then((res) => {
            if(res){
                callback(res);
            }
        })
    },
}